import { createPopupSlot } from '@/services/popupSlot'
import { getLogisticsStatusName } from '../../TrackOrder/utils'

export { getLogisticsStatusName }

export const popupSlot = createPopupSlot()

export const getRouteNodeName = Object.assign(
  (value: number | null | undefined) => {
    switch (value) {
      case 0:
        return '国内仓' as const
      case 1:
        return '起运港拖车' as const
      case 2:
        return '起运港' as const
      case 3:
        return '干线运输' as const
      case 4:
        return '目的港' as const
      case 5:
        return '目的港拖车' as const
      case 6:
        return '海外仓' as const
      case 7:
        return '尾程派送' as const
      case 8:
        return '目的地' as const
      default:
        return `${value ?? ''}` || null
    }
  },
  { valueList: [0, 1, 2, 3, 4, 5, 6, 7, 8] },
)

export const getRouteTypeName = Object.assign(
  (value: number | null | undefined) => {
    switch (value) {
      case 1:
        return '正常' as const
      case 2:
        return '异常' as const
      default:
        return `${value ?? ''}` || null
    }
  },
  { valueList: [1, 2] },
)

export const getErrorrTypeName = Object.assign(
  (value: number | null | undefined) => {
    switch (value) {
      case 0:
        return '监管异常' as const
      case 1:
        return '承运商异常' as const
      case 2:
        return '不可抗力异常' as const
      case 3:
        return '收件人异常' as const

      default:
        return `${value ?? ''}` || null
    }
  },
  { valueList: [0, 1, 2, 3] },
)

export const getBooleanName = (value: number | boolean | null | undefined) => {
  switch (value) {
    case 0:
    case false:
      return '否' as const
    case 1:
    case true:
      return '是' as const
    default:
      return null
  }
}
